import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.svm import SVR


def main():
    boston = pd.read_csv('./boston.csv')
    boston_data = boston.values[:, :13]
    boston_target = boston.values[:, 13]

    x_train, x_test, y_train, y_test = train_test_split(
        boston_data, boston_target, test_size=0.3, random_state=0)
    model = SVR(kernel='linear')  # linear线性核函数 poly多项式核函数 rbf高斯/径向基核函数 sigmoid核函数 precomputed提前计算好核函数矩阵
    model.fit(x_train, y_train)

    train_score = model.score(x_train, y_train)
    test_score = model.score(x_test, y_test)

    print(f"train score:{train_score:.2f}")
    print(f" test score:{test_score:.2f}")


if __name__ == '__main__':
    main()
